package cn.lx.demo;

import java.util.Random;

/**
 * @author lixin
 * @Classname Client
 * @Description TODO
 * @Date 2019/10/6 下午3:56
 */
public class Client {

    // 发送账单数量，这个值是从数据库中获取
    private static int MAX_COUNT = 6;

    public static void main(String[] args) {
        // 模拟发送邮件
        int i = 0;
        // 把模版定义出来
        Mail mail = new Mail(new AdvTemplate());

        mail.setTail("抬头");
        while (i < MAX_COUNT) {
            Mail clone = mail.clone();

            clone.setAppellation(getRandString(5) + "先森/女士");
            clone.setReceiver(getRandString(5) + ".com");
            sendMial(clone);
            i++;
        }
    }


    public static void sendMial(Mail mail) {
        System.out.println(mail.getAppellation() + "-" + mail.getReceiver());
    }

    public static String getRandString(Integer maxLength) {
        String source = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        StringBuffer sb = new StringBuffer();
        Random random = new Random();
        for (Integer i = 0; i < maxLength; i++) {
            sb.append(source.charAt(random.nextInt(source.length())));
        }
        return sb.toString();
    }


}
